package com.ruoyi.dwzzzy.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dwzzzy.domain.QualifSource;
import com.ruoyi.dwzzzy.service.IQualifSourceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 单位资质资源Controller
 * 
 * @author 张维
 * @date 2021-03-19
 */
@RestController
@RequestMapping("/business/dw")
public class QualifSourceController extends BaseController {
    @Autowired
    private IQualifSourceService qualifSourceService;

    /**
     * 查询单位资质资源列表
     */
//    @RequiresPermissions("business:dwzzzy:list")
    @PostMapping("/list")
    public TableDataInfo list(QualifSource qualifSource)
    {
        startPage();
        List<QualifSource> list = qualifSourceService.selectQualifSourceList(qualifSource);
        return getDataTable(list);
    }

    /**
     * 导出单位资质资源列表
     */
    @RequiresPermissions("business:dwzzzy:export")
    @Log(title = "单位资质资源", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QualifSource qualifSource)
    {
        List<QualifSource> list = qualifSourceService.selectQualifSourceList(qualifSource);
        ExcelUtil<QualifSource> util = new ExcelUtil<QualifSource>(QualifSource.class);
        return util.exportExcel(list, "dwzzzy");
    }

    /**
     * 获取单位资质资源详细信息
     */
    @RequiresPermissions("business:dwzzzy:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qualifSourceService.selectQualifSourceById(id));
    }

    /**
     * 新增单位资质资源
     */
//    @RequiresPermissions("business:dwzzzy:add")
    @Log(title = "单位资质资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(QualifSource qualifSource)
    {
        return toAjax(qualifSourceService.insertQualifSource(qualifSource));
    }

    /**
     * 修改单位资质资源
     */
//    @RequiresPermissions("business:dwzzzy:edit")
    @Log(title = "单位资质资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(QualifSource qualifSource)
    {
        return toAjax(qualifSourceService.updateQualifSource(qualifSource));
    }

    /**
     * 删除单位资质资源
     */
//    @RequiresPermissions("business:dwzzzy:remove")
    @Log(title = "单位资质资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qualifSourceService.deleteQualifSourceByIds(ids));
    }

}
